package com.lyf.scm.job.task;

import com.dangdang.ddframe.job.api.ShardingContext;
import com.lyf.scm.job.config.AbstractSimpleJob;
import com.lyf.scm.job.remote.facade.UpdatePlanCancelStatusFacade;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * description:
 * 其他渠道计划Job
 * @author: huangtao
 * @data: 2020/9/5
 */
@Slf4j
@Component
public class UpdatePlanCancelStatusJob extends AbstractSimpleJob {

    @Value("${elastic.job.updatePlanCancelStatusJob.jobName}")
    private String jobName;
    @Value("${elastic.job.updatePlanCancelStatusJob.cron}")
    private String cron;
    @Value("${elastic.job.updatePlanCancelStatusJob.shardingTotalCount}")
    private Integer shardingTotalCount;
    @Value("${elastic.job.updatePlanCancelStatusJob.shardingItemParameters}")
    private String shardingItemParameters;
    @Value("${elastic.job.updatePlanCancelStatusJob.failover}")
    private Boolean failover;
    @Value("${elastic.job.updatePlanCancelStatusJob.desc}")
    private String desc;

    @Resource
    private UpdatePlanCancelStatusFacade updatePlanCancelStatusFacade;

    @Override
    public void execute(ShardingContext shardingContext) {
        log.info("开始修改营销中心取消状态。。。");
        updatePlanCancelStatusFacade.updatePlanCancelStatus();
        log.info("修改营销中心取消状态完成。。。");
    }

    @Override
    public void run(String... args) throws Exception{
        // spring 启动完成后初始化job
        registerSimpleJob(jobName, cron, shardingTotalCount, shardingItemParameters, failover, desc);
    }
}
